import type { RequestMethod } from '@/types/handle'
import type { RoleTable } from '@/types/role'
import type { ButtonType, FormRules } from 'element-plus'
import { ref, type Ref } from 'vue'

export function getType(val: RequestMethod): ButtonType {
  if (val == 'GET') {
    return 'success'
  } else if (val == 'POST') {
    return 'warning'
  } else if (val == 'DELETE') {
    return 'danger'
  } else if (val == 'PUT') {
    return 'primary'
  }
  return 'default'
}

export const formRules: Ref<FormRules<RoleTable>> = ref<FormRules<RoleTable>>({
  key: [
    {
      required: true,
      message: '请输入角色标识'
    }
  ],
  name: [
    {
      required: true,
      message: '请输入角色名称'
    }
  ]
})
